package com.financing.platform.dao.impl;

import java.util.List;
import com.financing.platform.dao.impl.BaseDaoImpl;
import com.financing.platform.dao.IFpFundCompanyDao;
import com.financing.platform.dto.FpFundCompanyDTO;
import com.financing.platform.util.SqlName;
import java.sql.SQLException;
import java.util.Collections;

import org.springframework.stereotype.Repository;

/**
 * @Description:实现类
 * @author caojiayao
 * @version 1.0
 * @created 
 */
@Repository("fpFundCompany")
public class FpFundCompanyDaoImpl extends BaseDaoImpl implements IFpFundCompanyDao {
	
	@Override
	public FpFundCompanyDTO getFpFundCompany(FpFundCompanyDTO dto) {
		try{
			return (FpFundCompanyDTO)this.sqlMapClient.queryForObject(SqlName.fpFundCompany,dto);
		} catch (SQLException e) {
			log.error("get fpFundCompany error:",e);
			return null;
		}
	}
	
	
	@Override
	public Integer insertFpFundCompany(FpFundCompanyDTO dto) {
		try {
		     return (Integer) this.sqlMapClient.insert(SqlName.insertFpFundCompany,dto);
		} catch (SQLException e) {
			log.error("add fpFundCompany error:",e);
			return 0;
		}
	}

	
	@Override
	public Integer updateFpFundCompany(FpFundCompanyDTO dto) {
		try {
			return (Integer) this.sqlMapClient.update(SqlName.updateFpFundCompany, dto);
		} catch (SQLException e) {
			this.log.error("update fpFundCompany error 1!",e);
			return 0;
		}
	}
	
	@Override
	public Integer delFpFundCompany(Integer id) {
		try{
			 return (Integer) this.sqlMapClient.delete(SqlName.delFpFundCompany, id);
		} catch (SQLException e) {
			log.error("del fpFundCompany error:",e);
			return 0;
		}
	}
	
	@Override
	public List<FpFundCompanyDTO> listFpFundCompany(FpFundCompanyDTO dto) {
		try {
			return (List<FpFundCompanyDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundCompany, dto);
		} catch (SQLException e) {
			log.error("Query fpFundCompany note list error !", e);
			return Collections.emptyList();
		}
	}
	
	
	public Integer countFpFundCompany(FpFundCompanyDTO dto){
		try {
			return (Integer)this.sqlMapClient.queryForObject(SqlName.countFpFundCompany, dto);
		} catch (SQLException e) {
			log.error("Query fpFundCompany note list error !", e);
			return 0;
		}
	}


	public FpFundCompanyDTO getFpFundCompanyByManagerId(String managerId) {
		try{
			return (FpFundCompanyDTO)this.sqlMapClient.queryForObject(SqlName.getFpFundCompanyByManagerId,managerId);
		} catch (SQLException e) {
			log.error("get fpFundCompany error:",e);
			return null;
		}
	}


	public List<FpFundCompanyDTO> listFpFundCompanyByManagerId(String managerId) {
		try {
			return (List<FpFundCompanyDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundCompanyByManagerId, managerId);
		} catch (SQLException e) {
			log.error("Query fpFundCompany note list error !", e);
			return Collections.emptyList();
		}
	}


	public List<FpFundCompanyDTO> getFpFundCompanyByFundId(String managerId) {
		try{
			return (List<FpFundCompanyDTO>)this.sqlMapClient.queryForList(SqlName.getFpFundCompanyByFundId,managerId);
		} catch (SQLException e) {
			log.error("get fpFundCompany error:",e);
			return null;
		}
	}
	
}
